<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/**
 * View file: event_form
 *
 * @author hoanguyen
 * @since 17-02-2013
 */
?>
<div id="form_result"></div>
<article class="module width_full">
    <form method="POST" id="form" 
          action="<?php echo $id ? site_url("event/form/$id") : site_url("event/form") ?>">
        <header><h3><?php echo $title ?></h3></header>
        <div class="module_content">

            <fieldset style="width:48%; float:left; margin-right: 3%;">
                <label>Tên sự kiện</label>
                <input type="text" style="width:92%;" value="<?php echo isset($item['event_title']) ? $item['event_title'] : '' ?>"
                       name="event_title" required="required">
            </fieldset>
            
            Event_parent
            <script>
                $(function() {
                    var availableTags = [      
                    <?php foreach ($_event as $event_parent): ?>
                        <?php echo '"' . $event_parent['event_title'] . '",' ?>
                    <?php endforeach; ?> 
                            ];

                            $( "#event_parent" ).autocomplete({
                                source: availableTags
                            });
                        });
            </script>

            <fieldset style="width:48%; float:right;">
                <label>Sự kiện cha</label> <div style="float: right; margin-right: 3%;">Gõ tên sự kiện cha vào ô textbox</div>
                <input name="event_parent" id="event_parent" style="width:92%; margin-left: 3%;"
                       value="" >                    
            </fieldset>
            
            <fieldset style="width:48%; height: 170px; float:left; margin-right: 3%;">
                <label>Hình đại diện cho sự kiện</label>
                <div class="clear"></div>
                <div style="padding: 0 10px">                    
                    <span>
                        <a href="#" id="thumb_link">
                            <?php
                            $thumb = ($item['event_thumb'] != '') ? site_url('photo/gate/' . urlencode(urlencode(urlencode($item['event_thumb'])))) : base_url() . 'assets/css/_common/images/image.png';
                            ?>
                            <img src="<?php echo $thumb ?>" 
                                 style="max-height:128px;max-width:128px"/>                                                                                    
                        </a>
                        <input type="hidden" value="<?php echo $item['event_thumb'] ?>" name="event_thumb"/>
                    </span>                                            
                </div>
            </fieldset>
                        
            
            <fieldset style="width:48%; float:right;">
                <label>Tóm tắt nội dung sự kiện</label>
                <textarea rows="6" style="width:92%;" 
                          name="event_summary"><?php echo isset($item['event_summary']) ? $item['event_summary'] : '' ?></textarea>
            </fieldset>
                       

            <fieldset style="width:48%; float:right;">
                <label>Nội dung sự kiện</label>
                <textarea rows="6" style="width:92%;" 
                          name="event_content"><?php echo isset($item['event_content']) ? $item['event_content'] : '' ?></textarea>
            </fieldset>
            
            <fieldset style="width:48%; float:left; margin-right: 3%;">
                <label>Chọn Album ảnh cho sự kiện</label>
                <select name="event_album" style="width:70%;">
                    <option value=""> * Chưa có album</option>
                    <?php foreach ($albums as $album): ?>
                        <option value="<?php echo $album['album_id'] ?>"> <?php echo $album['album_name'] ?> </option>
                    <?php endforeach; ?>                    
                </select>
                <a href="../album/form"> Tạo album mới </a>
            </fieldset>
            
            video
            <script language="javascript"> 
                 function frame_url() 
                 {                 
                     $('#iframe').attr('src', document.getElementById('event_video').value);                        
                 } 
            </script>
            <fieldset style="width:48%; float:left;">
                <label>Video</label>
                <input type="text" style="width:92%;" id="event_video" value="<?php echo isset($item['event_video']) ? $item['event_video'] : '' ?> "
                    name="event_video" required="required" onchange="frame_url()">                        
                <iframe id="iframe"  style="margin: 3%;" width="92%" height="300px" src="<?php echo $item['event_video'] ?>"></iframe>'
            </fieldset>                                        

            <fieldset style="width:48%; float:right;">
                <label>Tag</label>
                <textarea rows="3" style="width:92%;" 
                          name="event_tags"><?php echo isset($item['event_tags']) ? $item['event_tags'] : '' ?></textarea>
                Nội dung hiển thị cho bộ máy tìm kiếm
            </fieldset>                                              
             

            Datetimepicker            
            <script src="<?php echo base_url(); ?>/assets/js/form/datetimepicker.js"></script>  
            <script>
                $(function($) {
                    $("#event_start").datetimepicker(); 
                    $("#event_end").datetimepicker();                    
                });                                   
            </script> 

            <fieldset style="width:48%; float:right;">
                <label>Thời gian bắt đầu</label>
                <input type="text" style="width:92%;" id="event_start" value="<?php echo isset($item['event_start']) ? date('m/d/Y h:i:s', $item['event_start']) : 1 ?>"
                       name="event_start" required="required">
            </fieldset>

            <fieldset style="width:48%; float:right;">
                <label>Thời gian kết thúc</label>
                <input type="text" style="width:92%;" id="event_end" value="<?php echo isset($item['event_end']) ? date('m/d/Y h:i:s', $item['event_end']) : 1 ?> "
                       name="event_end" required="required">
            </fieldset>
            <div class="clear"></div>
        </div>
                

        <footer>
            <div class="submit_link">
                <span class="loading">&nbsp;</span>                
                <input type="submit" value="Lưu lại" class="alt_btn">
                <input type="reset" value="Nhập lại">                
            </div>
        </footer>
    </form>
</article><!-- end of post new article -->


<div id="thumb_dialog" title="Upload ảnh đại diện cho ứng dụng từ máy của bạn">
    <div id="thumb_result" style="text-align: center"></div>
    <form method="POST" enctype="multipart/form-data"
          action="<?php echo site_url('event/upload_thumb') ?>" id="thumb_frm" >        
        <input type="file" name="userfile" size="20" id="thumb_file"/>        
        <div class="progressbar"></div>
    </form>    
</div>

